<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">

        <el-col :span="8">
          <el-form-item label="团队编号" prop="FCATNO">
            <el-input v-model="dataForm.FCATNO"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="所属课题组">
              <el-select v-model="dataForm.FPARENTNO" placeholder="请选择" >
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
         </el-col>

        <el-col :span="8">
            <el-form-item label="状态">
              <el-select v-model="dataForm.FSTATE" placeholder="请选择" >
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="8">
          <el-form-item label="团队名称" prop="FCATNAME">
            <el-input v-model="dataForm.FCATNAME"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="负责人">
              <el-select v-model="dataForm.FUSER" placeholder="请选择">
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="8">
          <el-form-item label="备注" prop="FMEMO">
            <el-input v-model="dataForm.FMEMO"   />
          </el-form-item>
        </el-col>

        <el-col :span="5">
          <el-form-item label="">
            <el-button type="success" icon="el-icon-plus" @click="insert">添加人员</el-button>
            <el-button type="primary" :loading="loading">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <el-table :data="list" border stripe>
      <el-table-column label="操作" width="80">
        <template slot-scope="scope">
          <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
            type="text">删除</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
      <el-table-column prop="FCATNO" label="人员编号" ></el-table-column>
      <el-table-column prop="FCATNAME" label="人员姓名"></el-table-column>
      <el-table-column prop="FWORK" label="工作分配" ></el-table-column>
      <el-table-column prop="FSTATE" label="状态" ></el-table-column>
    </el-table>
    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        title: "新增",
        insertorupdate: true,
        dataForm: {
          FPARENTNO:"化学系",
          FCATNO:"201",
          FCATNAME:"医疗垃圾智慧处理系统",
          FUSER: "曹操",
          FMEMO: "",
          FSTATE: "正常",
          FNOTE: ""
        },
        rules: {
          FCATNO:[
            { required: true, message: '请输入团队号码', trigger: 'blur' },
          ],
          FCATNAME: [
            { required: true, message: '请输入团队名称', trigger: 'blur' },
          ],
          FUSER: [
            { required: true, message: '请输入负责人', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FCATNO": "2410001",
                  "FCATNAME": "宋江",
                  "FWORK": "实验主持人",
                  "FSTATE":"在岗",
                },
                { "FENTRYID":2,
                  "FCATNO": "2410002",
                  "FCATNAME": "李逵",
                  "FWORK": "实验操作员",
                  "FSTATE":"在岗",
                }],
        loading: false,
        visible: false,

        options1: [{
          value: '1',
          label: '曹操'
        }, {
          value: '2',
          label: '刘备'
        }, {
          value: '3',
          label: '孙权'
        }],

        //所属校区选择数据
        options2: [{
          value: '1',
          label: '化学系'
        }, {
          value: '2',
          label: '分析测试中心'
        }, {
          value: '3',
          label: '食品安全与检测'
        }],

        options3: [{
          value: '1',
          label: '正常'
        }, {
          value: '2',
          label: '暂停'
        }, {
          value: '3',
          label: '解散'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>